package sim.util;

import java.util.* ;

import static sim.core.Simulation.*;

/**
 * Extends ArrayList with random-based operations.
 * @author smd
 *
 * @param <T> The type of the elements stored in this random array list
 */
@SuppressWarnings("serial")
public class RandomList<T> extends ArrayList<T>{

	public RandomList() {}

	public RandomList( Collection <? extends T> c) {
		super(c) ;
	}
	
	public T randomElement() {
		return isEmpty() ? null : get( rg.nextInt( size() ) ) ;
	}
	
	public T removeRandomElement() {
		return isEmpty() ? null : remove( rg.nextInt( size() ) ) ;		
	}
}
